/*
 * @Author: CodeHare
 * @Date: 2023-09-19 18:46:23
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-04-16 17:54:11
 * @Description: 
 */
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yt_devops/pages/devices/device_tab/device_detail/ems/rectangle_ems_romote_control/rectangle_battery_protection_parameter/rectangle_battery_protection_parameter_view.dart';
import 'package:yt_devops/pages/devices/device_tab/device_detail/ems/rectangle_ems_romote_control/rectangle_control_instruct/rectangle_control_instruct_view.dart';
import 'package:yt_devops/pages/devices/device_tab/device_detail/ems/rectangle_ems_romote_control/rectangle_ems_romote_control_controller.dart';
import 'package:yt_devops/pages/devices/device_tab/device_detail/ems/rectangle_ems_romote_control/rectangle_operating_parameter_settings/rectangle_operating_parameter_settings_view.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/styles/styles.dart';
import 'package:yt_devops/utils/enums.dart';

class RectangleEmsRomoteControlPage
    extends GetView<RectangleEmsRomoteControlController> {
  const RectangleEmsRomoteControlPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'siteMonitor.remoteControl'.tr,
          style: TextStyle(
            fontSize: 18.sp,
            fontWeight: FontWeight.w500,
          ),
        ),
        leading: GestureDetector(
          onTap: () => Get.back(),
          child: Icon(
            Platform.isAndroid ? Icons.arrow_back : Icons.arrow_back_ios,
            color: Colour.black,
          ),
        ),
      ),
      body: GestureDetector(
        behavior: HitTestBehavior.translucent,
        onTap: () {
          FocusScope.of(context).requestFocus(FocusNode());
        },
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Container(
                width: double.infinity,
                margin: const EdgeInsets.symmetric(
                  vertical: 10,
                ),
                color: Colour.white,
                child: RectangleControlInstructWidget(
                  deviceId: controller.deviceId!,
                ),
              ),

              /// 矩形才有电池保护参数
              if (controller.productId == ProductIDType.ems.value)
                RectangleBatteryProtectionParameterWidget(
                  deviceId: controller.deviceId!,
                ),
              Container(
                margin: const EdgeInsets.only(
                  bottom: 44,
                ),
                child: RectangleOperateParameterSettingWidget(
                  deviceId: controller.deviceId!,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
